package com.Smart.smartscals.Fragment;

import java.util.ArrayList;

import com.Smart.smartscals.Activity.R;
import com.Smart.smartscals.Adapter.CustomWeightPagerAdapter;
import com.Smart.smartscals.CustomView.CustomCircleView;
import com.Smart.smartscals.CustomView.CustomWeightView;
import com.Smart.smartscals.Entity.EntityCircleView;
import com.Smart.smartscals.Utils.Tools;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;

public class FragmentMainTarget extends BaseFragment {

	private CustomWeightView mCustomWeightView;
	private ArrayList<String> arrayListStr;
	private CustomCircleView mCustomCircleView;
	private EntityCircleView mEntityCircleView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		mView = inflater.inflate(R.layout.fragment_main_target, null);
		// TODO Auto-generated method stub
		return mView;
	}

	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		super.onViewCreated(view, savedInstanceState);
		initView();
		initParam();
		setListener();
	}

	private void setListener() {

		mCustomWeightView.setOnTouchListener(new OnTouchListener() {

			@Override
			public boolean onTouch(View v, MotionEvent event) {
				Tools.setLog("---->onTouch:" + event.getX());
				return false;
			}
			
		});

	}
	
	@Override
	public boolean onTouch(View arg0, MotionEvent arg1) {
		// TODO Auto-generated method stub
		Tools.setLog("---->onTouch--:" + arg1.getX());

		return super.onTouch(arg0, arg1);
	}

	private void initParam() {
		arrayListStr = new ArrayList<String>();
		arrayListStr.add("");
		arrayListStr.add("01");
		arrayListStr.add("02");
		arrayListStr.add("03");
		arrayListStr.add("04");
		arrayListStr.add("05");

		arrayListStr.add("06");
		arrayListStr.add("02");
		arrayListStr.add("07");
		arrayListStr.add("08");
		arrayListStr.add("09");
		arrayListStr.add("00");

		arrayListStr.add("06");
		arrayListStr.add("06");
		arrayListStr.add("05");
		arrayListStr.add("03");
		arrayListStr.add("02");
		arrayListStr.add("02");
		arrayListStr.add("01");
		arrayListStr.add("08");
		arrayListStr.add("");

		mCustomWeightView.statrTration(arrayListStr);

		mEntityCircleView = new EntityCircleView("955.0", "现在", "斤", null);

		mCustomCircleView.initParam(mEntityCircleView);
//		mCustomCircleView.statAniMation();
		
	}

	private void initView() {
		mCustomWeightView = (CustomWeightView) mView
				.findViewById(R.id.main_report_customweightselected);
		mCustomCircleView = (CustomCircleView) mView
				.findViewById(R.id.fragment_taget_circleview);

	}

	@Override
	public void onDestroyView() {
		// TODO Auto-generated method stub
		super.onDestroyView();

		// for (int i = 0; i < mCustomWeightView.getTmArrayList().size(); i++) {
		// mCustomWeightView.getTmArrayList().get(i).recycle();
		// }

	}
}
